<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Domain extends Model
{
    use HasFactory;

    protected $fillable = ['name', 'description'];

    public function teams()
    {
        return $this->hasMany(Team::class, 'domain_id');
    }

    public function users()
    {
        return $this->belongsToMany(User::class, 'domain_user');
    }

    public function hirings()
    {
        return $this->hasMany(Hiring::class, 'domain_id');
    }

    public function teamSearches()
    {
        return $this->hasMany(TeamSearch::class, 'domain_id');
    }

    public function chatMessages()
    {
        return $this->morphMany(ChatMessage::class, 'message_parent_model');
    }

    public function roles()
    {
        return $this->hasMany(DomainRole::class, 'domain_id');
    }
}
